//POJ 3784
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <functional>
using namespace std;

int n;
int input[10000];

// 1-based
template <typename T, int MaxHeapSize, typename _Compare = std::less<T> >
class BinaryHeap
{
public:
	BinaryHeap()
	{
		clear();
	}
	T top() const
	{
		if (!empty())
		{
			return tree[1];
		}
		else
		{
			//throw std::logic_error("Empty Heap");
			return tree[1];
		}
	}
	void pop()
	{
		if (!empty())
		{
			swap(tree[1], tree[_size]);
			--_size;
			if (!empty())
			{
				siftDown(1);
			}
		}
	}
	void push(const T &val)
	{
		tree[++_size] = val;
		siftUp(_size);
	}
	int size() const
	{
		return _size;
	}
	bool empty() const
	{
		return _size == 0;
	}
	void clear()
	{
		_size = 0;
	}
	void updateValueAt(int idx, const T &newValue)
	{
		if (comp(newValue, tree[idx]))
		{
			tree[idx] = newValue;
			siftUp(idx);
		}
		else
		{
			tree[idx] = newValue;
			siftDown(idx);
		}
	}

private:
	void siftUp(int idx)
	{
		while (idx != 1)
		{
			if (comp(tree[idx], tree[idx / 2]))
			{
				swap(tree[idx], tree[idx / 2]);
			}
			idx /= 2;
		}
	}
	void siftDown(int idx)
	{
		int midx = idx;
		if (2 * idx <= _size && comp(tree[2 * idx], tree[midx]))
			midx = 2 * idx;
		if (2 * idx + 1 <= _size && comp(tree[2 * idx + 1], tree[midx]))
			midx = 2 * idx + 1;
		if (midx != idx)
		{
			swap(tree[idx], tree[midx]);
			siftDown(midx);
		}
	}

private:
	T tree[MaxHeapSize + 1];
	int _size;
	_Compare comp;
};

BinaryHeap<int, 10000, greater<int> > leftHeap;
BinaryHeap<int, 10000, less<int> > rightHeap;

int main()
{
	int no;
	scanf("%d", &no);
	while (no--)
	{
		leftHeap.clear();
		rightHeap.clear();
		int idx;
		scanf("%d%d", &idx, &n);
		for (int i = 0; i < n; i++)
		{
			scanf("%d", &input[i]);
		}
		int cnt = 1;
		int median = input[0];
		printf("%d %d\n", idx, (n + 1) / 2);
		printf("%d ", median);
		for (int i = 1; i < n; i++)
		{
			if ((i & 1)  == 0)
			{
				int a = input[i - 1];
				int b = input[i];
				if (a <= median && b >= median)
				{
					leftHeap.push(a);
					rightHeap.push(b);
				}
				else if (b <= median && a >= median)
				{
					leftHeap.push(b);
					rightHeap.push(a);
				}
				else if (a < median && b < median)
				{
					leftHeap.push(a);
					leftHeap.push(b);
					int temp = leftHeap.top();
					leftHeap.pop();
					rightHeap.push(median);
					median = temp;
				}
				else if (a > median && b > median)
				{
					rightHeap.push(a);
					rightHeap.push(b);
					int temp = rightHeap.top();
					rightHeap.pop();
					leftHeap.push(median);
					median = temp;
				}
				if (++cnt == 10)
				{
					cnt = 0;
					printf("%d\n", median);
				}
				else
					printf("%d ", median);
			}
		}
		printf("\n");
	}
	system("pause");
	return 0;
}